package com.fang.springcrud.dao;

import com.fang.springcrud.entity.UserEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;

import java.util.List;

public interface UserDao {

    /**
     * 查询列表
     *
     * @param page
     * @param limit
     * @param key
     * @return
     */
    List<UserEntity> queryList(@Param("page") int page, @Param("limit") int limit, @Param("key") String key);

    /**
     * 查询数量
     *
     * @param key
     * @return
     */
    @Select("select count(1) from User where username like concat('%',#{key},'%')")
    int count(String key);

    @Select("select * from User where id =#{id}")
    UserEntity selectForId(String id);

    int updateEntity(UserEntity entity);

    void deleteForIds(int[] ids);
    
    @Insert("insert into User(username,password) values(#{username},#{password})")
    void save(UserEntity entity);
}
